<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：学校组件
-->

<template>
	<div>	
		<div style="padding-top:10px;">
			<Form ref="params" :model="params" :rules="ruleValidate" :label-width="100" label-position="right">		
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 37.5%;text-align: left;float: left;" align="left">
						<FormItem label="校区名称" prop="csname">
							<Input v-model="params.csname" placeholder="请输入校区名称!" clearable style="width: 100%;"></Input>
						</FormItem>
					</div>
				</div>
	
				<div style="width:100%;float:left;">
					<div style="width: 100%;text-align: left;float: left;" align="left">
						<FormItem prop="jianjie"  label="校区简介" >
							<Input v-model.trim="params.jianjie" type="textarea" :rows="15" style="width: 86.5%;" placeholder="请输入校区简介！" />
						</FormItem>
					</div>
				</div>
			</Form>	
		</div>
		<div style="width:100%;height: 60px;line-height: 60px;float:left;margin-bottom: 20px;">
			<Button type="info" style="float:left;margin-left:10%;" v-on:click="save()">保存</Button>
		</div>	
	</div>
</template>

<script>
	export default {
		name:"home",
		data() {
			//长度控制
			const lenPass = (rule, str, callback) => {
			  if(str.length>rule.length){
			  	 callback(new Error('字符串长度在1-'+rule.length+'之间！'));
			  }
			  return callback();
			};
			return {
				params:{
					csid:'',
					csname:'',
					jianjie:''
				},
				ruleValidate: {
					csname: [
						{required: true,message: '请填写校区名称！',trigger: 'blur'},
						{length:100,validator:lenPass,trigger:'blur'}
					],
					jianjie: [
						{required: true,message: '请填写校区简介！',trigger: 'blur'},
						{length:1000,validator:lenPass,trigger:'blur'},
					]
				},
				
			}
		},
		components: {
			
		},
		computed: {
			
		},
		methods: {
			getCanpus(){
				this.$http.get("/host/stgl/campus/getCampusBycsid.html")
				.then(result => {
					this.params.csid=result.CSID;
					this.params.csname=result.CSNAME;
					this.params.jianjie=result.JIANJIE;
				});
			},
			save(){
				const params={
					csid:this.params.csid,
					csname:this.params.csname,
					jianjie:this.params.jianjie
				}
				this.$http.post("/host/stgl/campus/updateCampus.html",params)
				.then(datas => {
					if(datas){
						this.$Modal.success({
                            title: "提示",
                            content: "保存成功"
                        });	
					}else{
						this.$Modal.error({
                            title: "提示",
                            content:"保存失败"
                        });	
					}
				});
				
			}
		},
		mounted(){	
			//获取校区信息
			this.getCanpus();
		}
	}
</script>


<style scoped="scoped">
	
</style>



